import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Person {

	private String lastName;
	private String firstName;
	private String gender;
	private Date dob;
	private String color;
	
	public Person(String ln, String fn, String gender, String dob, String clr) {
		this.lastName = ln;
		this.firstName = fn;
		this.gender = gender;
		this.dob = tryParse(dob);
		this.color = clr;
	}
	
	static Date tryParse(String dateString)
	{
		String[] formatStrings = {"M/d/y", "M-d-y"};

		for (String formatString : formatStrings)
	    {
	        try
	        {
	            return new SimpleDateFormat(formatString).parse(dateString);
	        }
	        catch (ParseException e) {}
	    }

	    return null;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public String getGender() {
		return gender;
	}
	
	public Date getDob() {
		return dob;
	}
	
	public String getColor() {
		return color;
	}
	
	public String toString() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy");
		//System.out.println(dateFormat.format(dateFormat.parse("31/05/2011")));
		return lastName + " " + firstName + " " + gender + " " + dateFormat.format(dob) + " " + color;
		
	}
}
